<?php
    /**
    * Show the featured project list
    * This action can only be called from view action
    * Dont need to call it directly
    * 
    * @author trungdt
    * @since June 25, 2011
    * 
    * Change logs
    * 
    */

    if (!defined('EXPONENT')) exit;
    define('AB_HTML_NULL',"<p>&#160;</p>");

    global $db;
    $id=-1;
    $sql_where=" featured = 1";

    $config=$db->selectObject("duanmodule_config","location_data = '".serialize($loc)."'");

    $template = new template('duanmodule',"_view_detail_featured",$loc);

    $projects= $db->selectObjects('duan'," location_data='".serialize($loc)."' AND {$sql_where} LIMIT 0,20");
    foreach ($projects as $k=>$project)
    {
        //location
        $province=duanmodule::_GetProvince_byID(intval($project->province_id));
        $ward = duanmodule::_GetWard_byID(intval($project->province_ward_id), ($project->province_id));
        $project->location=$ward->name;

        // for thumbnail
        if ($project->thumbnail <= 0) {
            $project->thumbnail_path = '';
        } else {
            $file = $db->selectObject('file', 'id='.$project->thumbnail);
            $project->thumbnail_path = BASE_URL."/".$file->directory.'/'.$file->filename;
        }
        
        $project->src=unserialize($project->location_data)->src;
    }
    //$template->register_permissions(array('administrate','configure','edit','create','delete'),$loc);
    if (isset($_REQUEST['load_css']))
    {
        $template->assign('load_css', 0);
    }
    else
    {
        $template->assign('laod_css', 1);
    }
    $template->assign('projects', $projects);
    $template->output();
?>
